package com.service.impl;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dao.IStudentDao;
import com.service.IStudentService;
import com.vo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

@Service
public class StudentServiceImpl implements IStudentService {

    @Autowired
    private IStudentDao iStudentDao;

    @Override
    public List<Student> list() {
        return this.iStudentDao.findAll();
    }

    @Override
    public Student get(String id) {
        return this.iStudentDao.selectById(id);
    }

    @Override
    public boolean add(Student vo) {
        return this.iStudentDao.insert(vo) > 0;
    }

    @Override
    public boolean delete(Set<String> ids) {
        return this.iStudentDao.deleteBatchIds(ids) == ids.size();
    }
    @Override
    public  Object getStudentnumber(String studentnumber){ return this.iStudentDao.getStudentnumber(studentnumber); }
    @Override
    public  boolean deleteStudentnumber(String studentnumber){ return this.iStudentDao.deleteStudentnumber(studentnumber); }

    @Override
    public IPage<Student> listSplit(String column, String keyword, Integer currentPage, Integer lineSize) {
        QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(column, keyword); // 模糊查询
        int count = this.iStudentDao.selectCount(queryWrapper); // 统计数据行数
        IPage<Student> page = new Page<>(currentPage, lineSize, count);
        return this.iStudentDao.selectPage(page, queryWrapper);
    }

}
